package com.bing.jh.service.impl;

import cn.hutool.core.text.CharSequenceUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bing.bingPro.util.ProvinceUtil;
import com.bing.jh.domain.DzWzCostMatchStat;
import com.bing.jh.entity.dto.TZwArchivesDto;
import com.bing.jh.entity.vo.DzWzCostMatchStatVO;
import com.bing.jh.entity.vo.DzWzUserGroupStatVO;
import com.bing.jh.mapper.DzWzCostMatchStatMapper;
import com.bing.jh.service.DzWzCostMatchStatService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ck
 * @description 针对表【dz_wz_cost_match_stat】的数据库操作Service实现
 * @createDate 2024-06-09 15:00:12
 */
@Service
public class DzWzCostMatchStatServiceImpl extends ServiceImpl<DzWzCostMatchStatMapper, DzWzCostMatchStat>
        implements DzWzCostMatchStatService {

    @Override
    public List<DzWzCostMatchStatVO> list(TZwArchivesDto tZwArchives) {
        tZwArchives.setMonth(tZwArchives.getMonth().replace("-", ""));
        /*if (!UserSecurityUtil.orAdminAllData()) {
            String realProvince = UserSecurityUtil.getCnRegion("");
            tZwArchives.setProvince(ProvinceUtil.queryCode(realProvince));
            tZwArchives.setFlag("1");
        }
        List<DzWzCostMatchStatVO> list = baseMapper.list(tZwArchives);
        if (CharSequenceUtil.isEmpty(tZwArchives.getCounty())) {
            if (!UserSecurityUtil.orAdminAllData()) {
                tZwArchives.setProvince(null);
            }
            DzWzCostMatchStatVO dzWzCostMatchStatVO = baseMapper.queryCn(tZwArchives);
            list.add(0, dzWzCostMatchStatVO);
        }*/
        tZwArchives.setProvinceCode(ProvinceUtil.getProvinceCode(tZwArchives.getProvinceCode()));
        List<DzWzCostMatchStatVO> list = baseMapper.list(tZwArchives);
        if (CharSequenceUtil.isEmpty(tZwArchives.getCounty())) {
            DzWzCostMatchStatVO dzWzCostMatchStatVO = baseMapper.queryCn(tZwArchives);
            list.add(0, dzWzCostMatchStatVO);
        }
        return list;
    }

    @Override
    public List<String> dateList() {
        return baseMapper.dateList();
    }

    @Override
    public List<DzWzCostMatchStatVO> queryAll(TZwArchivesDto tZwArchives) {
        tZwArchives.setMonth(tZwArchives.getMonth().replace("-", ""));
        tZwArchives.setProvinceCode(ProvinceUtil.getProvinceCode(tZwArchives.getProvinceCode()));
        List<DzWzCostMatchStatVO> list = baseMapper.list(tZwArchives);
        List<DzWzCostMatchStatVO> dzWzCostMatchStatVOList = baseMapper.queryCity(tZwArchives);
        list.addAll(dzWzCostMatchStatVOList);
        if (CharSequenceUtil.isEmpty(tZwArchives.getCounty())) {
            DzWzCostMatchStatVO dzWzCostMatchStatVO = baseMapper.queryCn(tZwArchives);
            list.add(0, dzWzCostMatchStatVO);
        }
        return list;
    }
}




